/**
 * Copyright (c) 2002-2011 旭鸣信息
 * All rights reserved. 
 * File：ConsumeLogContorller.java
 * History:
 *       May 13, 2012: Initially created, liuzhi.
 */
package com.xteam.ecsystem.contorller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.tangkf.utils.bean.ReqHelper;
import com.xteam.ecsystem.service.admin.ConsumeLogService;
import com.xteam.ecsystem.service.admin.SystemLogService;
import com.xteam.ecsystem.utils.ConstantLocation;

/**
 * 消费日志控制枢纽站
 * @author liuzhi
 *
 */
@Controller
public class ConsumeLogContorller {

	@Autowired
	private ConsumeLogService consumeLogService;
	
	@Autowired
	private SystemLogService systemLogService;
	
	@RequestMapping("/getConsumeLogList.do")
	public void getConsumeLogList(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws IOException {
		int pageIndex = ReqHelper.getRequestInt(request, "pageIndex");
		int pageSize = ReqHelper.getRequestInt(request, "pageSize");
		String bmbNick = ReqHelper.getRequestString(request, "bmbNick");
		String startTime = ReqHelper.getRequestString(request, "startTime");
		String endTime = ReqHelper.getRequestString(request, "endTime");
		
		String strList = consumeLogService.getConsumeLogList(pageIndex, pageSize, bmbNick, 
				startTime, endTime);
		response.getWriter().write(strList);
	}
	
	@RequestMapping("/delConsumeLogByIds.do")
	public void delConsumeLogByIds(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws IOException {
		String lclIds = ReqHelper.getRequestString(request, "lclIds");
		String lslUser = ReqHelper.getRequestString(request, "lslUser");
		String lslAddress = ReqHelper.getRequestString(request, "lslAddress");

		this.consumeLogService.delConsumeLogsByIds(lclIds);
		
		this.systemLogService.saveSystemLogs(lslUser, lslAddress, ConstantLocation.LOG_CONSUMELOG_MGR, 
				"delConsumeLogsByIds", ConstantLocation.LOG_BATCH_DELETE, "LogConsumeLog");
	}
	
	@RequestMapping("/delConsumeLogByCon.do")
	public void delConsumeLogByCon(HttpServletRequest request,
			HttpServletResponse response, ModelMap modelMap) throws IOException {
		String condition = ReqHelper.getRequestString(request, "condition");
		String lslUser = ReqHelper.getRequestString(request, "lslUser");
		String lslAddress = ReqHelper.getRequestString(request, "lslAddress");

		this.consumeLogService.delConsumeLogByCon(condition);
		
		this.systemLogService.saveSystemLogs(lslUser, lslAddress, ConstantLocation.LOG_CONSUMELOG_MGR, 
				"delConsumeLogByCon", ConstantLocation.LOG_BATCH_DELETE, "LogConsumeLog");
	}
	
	
}
